package info.yaohua.util;

import java.util.Vector;

public class UtilHelper {
	
	/**
	 * select sql生成器
	 * @param tableName
	 * @param paramList
	 * @return
	 */
	public static String selectSqlCreate(String tableName,Vector paramList)
	{
		String sql = "select * from "
				+tableName
				+" where ";
		for(int i=0;i<paramList.size();i++)
		{
			if(i!=0)
			{
				sql += "and ";
			}
			sql += paramList.get(i).toString() + " = ? ";
		}
		
			
		return sql;
		
	}
	

	/**
	 * insert sql 生成器		
	 * @param tableName
	 * @param count
	 * @return
	 */
	public static String insertSqlCreate(String tableName,int count)
	{
		String sql = "insert into "
				+tableName
				+" values (";
		for (int i=0;i<count;i++)
		{
			if(i==0)
			{
				sql += " ? ";
			}
			else
			{
				if(i==count-1)
				{
					sql += " ,?)";
				}
				else
				{
					sql += " ,? ";
				}
				
			}
		}
		return sql;
		
	}
	
}

